* s~\t+$~~
[lhc/web/wiklou.git] / includes / Linker.php
index 3348c58..bfe45eb 100644 (file)
@@ -174,7 +174,7 @@ class Linker {
                        }
 
                        $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>";
-                               
+
                        wfProfileOut( $fname );
                        return $t;
                } elseif ( $nt->isAlwaysKnown() ) {
@@ -238,7 +238,7 @@ class Linker {
                        wfProfileOut( $fname );
                        return $text;
                }
-               
+
                $u = $nt->escapeLocalURL( $query );
                if ( '' != $nt->getFragment() ) {
                        if( $nt->getPrefixedDbkey() == '' ) {
@@ -260,7 +260,7 @@ class Linker {
                $style = $this->getInternalLinkAttributesObj( $nt, $text );
 
                if ( $aprops !== '' ) $aprops = ' ' . $aprops;
-               
+
                list( $inside, $trail ) = Linker::splitTrail( $trail );
                $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
                wfProfileOut( $fname );
@@ -291,7 +291,7 @@ class Linker {
                        $text = htmlspecialchars( $nt->getPrefixedText() );
                }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
-               
+
                list( $inside, $trail ) = Linker::splitTrail( $trail );
                $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
 
@@ -375,17 +375,21 @@ class Linker {
        }
 
        /** @todo document */
-       function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, 
-         $thumb = false, $manual_thumb = '' ) 
+       function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false,
+         $thumb = false, $manual_thumb = '' )
        {
                global $wgContLang, $wgUser, $wgThumbLimits;
-               
+
                $img   = new Image( $nt );
+               if ( !$img->allowInlineDisplay() ) {
+                       return $this->makeKnownLinkObj( $nt );
+               }
+
                $url   = $img->getViewURL();
                $prefix = $postfix = '';
-               
+
                wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
-               
+
                if ( 'center' == $align )
                {
                        $prefix  = '<div class="center">';
@@ -406,17 +410,17 @@ class Linker {
                                $align = $wgContLang->isRTL() ? 'left' : 'right';
                        }
 
-                       
+
                        if ( $width === false ) {
                                $wopt = $wgUser->getOption( 'thumbsize' );
 
                                if( !isset( $wgThumbLimits[$wopt] ) ) {
                                         $wopt = User::getDefaultOption( 'thumbsize' );
                                }
-                               
+
                                $width = min( $img->getWidth(), $wgThumbLimits[$wopt] );
                        }
-                       
+
                        return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix;
                }
 
@@ -483,7 +487,7 @@ class Linker {
                if ( $img->exists() ) {
                        $width  = $img->getWidth();
                        $height = $img->getHeight();
-               } 
+               }
                if ( 0 == $width || 0 == $height ) {
                        $width = $height = 200;
                }
@@ -555,7 +559,7 @@ class Linker {
                $s .= '  <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
                return str_replace("\n", ' ', $s);
        }
-       
+
        /**
         * Pass a title object, not a title string
         */
@@ -586,7 +590,7 @@ class Linker {
                wfProfileOut( $fname );
                return $s;
        }
-       
+
        /** @todo document */
        function makeMediaLink( $name, /* wtf?! */ $url, $alt = '' ) {
                $nt = Title::makeTitleSafe( NS_IMAGE, $name );
@@ -605,18 +609,15 @@ class Linker {
         * @access public
         * @todo Handle invalid or missing images better.
         */
-       function makeMediaLinkObj( $title, $text = '', $nourl=false ) {
+       function makeMediaLinkObj( $title, $text = '' ) {
                if( is_null( $title ) ) {
                        ### HOTFIX. Instead of breaking, return empty string.
                        return $text;
                } else {
-                       $name = $title->getDBKey();     
+                       $name = $title->getDBKey();
                        $img  = new Image( $title );
                        if( $img->exists() ) {
                                $url  = $img->getURL();
-                               if( $nourl ) {
-                                       $url = str_replace( "http://", UNIQ_PREFIX . "NOPARSEhttp://", $url );
-                               }
                                $class = 'internal';
                        } else {
                                $upload = Title::makeTitle( NS_SPECIAL, 'Upload' );
@@ -628,7 +629,7 @@ class Linker {
                                $text = $alt;
                        }
                        $u = htmlspecialchars( $url );
-                       return "<a href=\"{$u}\" class='$class' title=\"{$alt}\">{$text}</a>";                  
+                       return "<a href=\"{$u}\" class='$class' title=\"{$alt}\">{$text}</a>";
                }
        }
 
@@ -673,7 +674,7 @@ class Linker {
        function formatComment($comment, $title = NULL) {
                $fname = 'Linker::formatComment';
                wfProfileIn( $fname );
-               
+
                global $wgContLang;
                $comment = str_replace( "\n", " ", $comment );
                $comment = htmlspecialchars( $comment );
@@ -737,22 +738,30 @@ class Linker {
                wfProfileOut( $fname );
                return $comment;
        }
-       
+
        /**
         * Wrap a comment in standard punctuation and formatting if
         * it's non-empty, otherwise return empty string.
         *
         * @param string $comment
         * @param Title $title
+        * @param bool $deleted
+        *
         * @return string
-        * @access public
         */
-       function commentBlock( $comment, $title = NULL ) {
+       function commentBlock( $comment, $title = NULL, $deleted = false ) {
+               // '*' used to be the comment inserted by the software way back
+               // in antiquity in case none was provided, here for backwards
+               // compatability, acc. to brion -ævar
                if( $comment == '' || $comment == '*' ) {
                        return '';
                } else {
-                       $formatted = $this->formatComment( $comment, $title );
-                       return " <span class='comment'>($formatted)</span>";
+                       if ( $deleted )
+                               return " <span class='comment'>(...)</span>";
+                       else {
+                               $formatted = $this->formatComment( $comment, $title );
+                               return " <span class='comment'>($formatted)</span>";
+                       }
                }
        }
 
@@ -786,7 +795,7 @@ class Linker {
                global $wgJsMimeType;
                $title =  wfMsgForContent('toc') ;
                return
-                  '<table id="toc" class="toc" summary="' . $title .'"><tr><td>' 
+                  '<table id="toc" class="toc" summary="' . $title .'"><tr><td>'
                 . '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
                 . $toc
                 . "</ul>\n</td></tr></table>\n"
@@ -835,10 +844,10 @@ class Linker {
                return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
        }
 
-       /** 
+       /**
         * Split a link trail, return the "inside" portion and the remainder of the trail
         * as a two-element array
-        * 
+        *
         * @static
         */
        function splitTrail( $trail ) {